package com.douyu.ocean.invoke.demo;

import com.douyu.ocean.invoke.PerfomanceAopUtil;
import com.douyu.ocean.invoke.PerfomanceAopUtil.MethodHandler;
import com.douyu.ocean.invoke.PerformanceCollectUtil;

import java.util.Random;

/**
 * @author leiruiqi on 2018/7/30
 */


public class TestAopUtil {

    private void aVoid(){
        System.out.println("do aVoid");
    }

    private Integer bReturn(){
       // System.out.println("do bReturn");
        int num = new Random().nextInt(100);
        if(num<50){
            throw new RuntimeException();
        }
        return 1;
    }
    public static void main(String[] args) {

        TestAopUtil aopTest = new TestAopUtil();
        PerformanceCollectUtil.init();
        Integer a = null;

        for(int i=0;i<1000;i++){
            a = (Integer) PerfomanceAopUtil.doHandler(new MethodHandler(){
                @Override
                public Integer getResponse() {
                    return aopTest.bReturn();
                }


            },"abctest",0d,false);

            if(i==500){
                PerformanceCollectUtil.dataAnalysis();
            }
        }

        PerformanceCollectUtil.dataAnalysis();

    }
}
